const express = require('express');
const router = express.Router();
const { 
  getTeachers, 
  getTeacherById, 
  createTeacher, 
  updateTeacher, 
  deleteTeacher 
} = require('../controllers/teacherController');
const { protect, admin } = require('../middleware/auth');

// 所有路由都需要认证，且需要管理员权限
router.use(protect);
router.use(admin);

// 获取所有老师
router.get('/', getTeachers);

// 获取单个老师
router.get('/:id', getTeacherById);

// 创建老师
router.post('/', createTeacher);

// 更新老师
router.put('/:id', updateTeacher);

// 删除老师
router.delete('/:id', deleteTeacher);

module.exports = router;
